# 导入工作流
from llama_index.core.workflow import (
    StartEvent, # 开始节点
    StopEvent, # 结束节点
    Workflow, # 需要继承对象
    step, # 节点
)


class MyWorkflow(Workflow):
    @step
    async def my_step(self, ev: StartEvent) -> StopEvent:
        return StopEvent(result="Hello, world!")


async def main():
    w = MyWorkflow(timeout=10, verbose=False)
    # await关键字：用于等待异步操作完成，只能在async函数内使用。
    result = await w.run()
    print(result)


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())